<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>13 L | Glossary</title>
<meta name="author" content="psyTeachR Team">
<meta name="description" content="13.1 LaTeX A typesetting program needed to create PDF files from R Markdown documents. \({\LaTeX}\) is pronounced &lt;&gt; or &lt;&gt; (the X is a chi) and you can make the fancy version in R Markdown using...">
<meta name="generator" content="bookdown 0.24 with bs4_book()">
<meta property="og:title" content="13 L | Glossary">
<meta property="og:type" content="book">
<meta property="og:url" content="https://psyteachr.github.io/glossary/l.html">
<meta property="og:image" content="https://psyteachr.github.io/glossary/images/logos/logo.png">
<meta property="og:description" content="13.1 LaTeX A typesetting program needed to create PDF files from R Markdown documents. \({\LaTeX}\) is pronounced &lt;&gt; or &lt;&gt; (the X is a chi) and you can make the fancy version in R Markdown using...">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="13 L | Glossary">
<meta name="twitter:description" content="13.1 LaTeX A typesetting program needed to create PDF files from R Markdown documents. \({\LaTeX}\) is pronounced &lt;&gt; or &lt;&gt; (the X is a chi) and you can make the fancy version in R Markdown using...">
<meta name="twitter:image" content="https://psyteachr.github.io/glossary/images/logos/logo.png">
<!-- JS --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/fuse.js/6.4.6/fuse.js" integrity="sha512-zv6Ywkjyktsohkbp9bb45V6tEMoWhzFzXis+LrMehmJZZSys19Yxf1dopHx7WzIKxr5tK2dVcYmaCk2uqdjF4A==" crossorigin="anonymous"></script><script src="https://kit.fontawesome.com/6ecbd6c532.js" crossorigin="anonymous"></script><script src="libs/header-attrs-2.11/header-attrs.js"></script><script src="libs/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="libs/bootstrap-4.6.0/bootstrap.min.css" rel="stylesheet">
<script src="libs/bootstrap-4.6.0/bootstrap.bundle.min.js"></script><script src="libs/bs3compat-0.3.1/transition.js"></script><script src="libs/bs3compat-0.3.1/tabs.js"></script><script src="libs/bs3compat-0.3.1/bs3compat.js"></script><link href="libs/bs4_book-1.0.0/bs4_book.css" rel="stylesheet">
<script src="libs/bs4_book-1.0.0/bs4_book.js"></script><script src="libs/kePrint-0.0.1/kePrint.js"></script><link href="libs/lightable-0.0.1/lightable.css" rel="stylesheet">
<!-- Global site tag (gtag.js) - Google Analytics --><script async src="https://www.googletagmanager.com/gtag/js?id=G-6NP3MF25W3"></script><script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', 'G-6NP3MF25W3');
    </script><script src="https://cdnjs.cloudflare.com/ajax/libs/autocomplete.js/0.38.0/autocomplete.jquery.min.js" integrity="sha512-GU9ayf+66Xx2TmpxqJpliWbT5PiGYxpaG8rfnBEk1LL8l1KGkRShhngwdXK1UgqhAzWpZHSiYPc09/NwDQIGyg==" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.11.1/mark.min.js" integrity="sha512-5CYOlHXGh6QpOFA/TeTylKLWfB3ftPsde7AnmhuitiTX4K5SqCLBeKro6sPS8ilsz1Q4NRx3v8Ko2IBiszzdww==" crossorigin="anonymous"></script><!-- CSS --><link rel="stylesheet" href="include/psyteachr.css">
<link rel="stylesheet" href="include/webex.css">
<link rel="stylesheet" href="include/style.css">
</head>
<body data-spy="scroll" data-target="#toc">

<div class="container-fluid">
<div class="row">
  <header class="col-sm-12 col-lg-3 sidebar sidebar-book"><a class="sr-only sr-only-focusable" href="#content">Skip to main content</a>

    <div class="d-flex align-items-start justify-content-between">
      <h1>
        <a href="index.html" title="">Glossary</a>
      </h1>
      <button class="btn btn-outline-primary d-lg-none ml-2 mt-1" type="button" data-toggle="collapse" data-target="#main-nav" aria-expanded="true" aria-controls="main-nav"><i class="fas fa-bars"></i><span class="sr-only">Show table of contents</span></button>
    </div>

    <div id="main-nav" class="collapse-lg">
      <form role="search">
        <input id="search" class="form-control" type="search" placeholder="Search" aria-label="Search">
</form>

      <nav aria-label="Table of contents"><h2>Table of contents</h2>
        <ul class="book-toc list-unstyled">
<li><a class="" href="index.html">Overview</a></li>
<li><a class="" href="symbols.html"><span class="header-section-number">1</span> Symbols</a></li>
<li><a class="" href="a.html"><span class="header-section-number">2</span> A</a></li>
<li><a class="" href="b.html"><span class="header-section-number">3</span> B</a></li>
<li><a class="" href="c.html"><span class="header-section-number">4</span> C</a></li>
<li><a class="" href="d.html"><span class="header-section-number">5</span> D</a></li>
<li><a class="" href="e.html"><span class="header-section-number">6</span> E</a></li>
<li><a class="" href="f.html"><span class="header-section-number">7</span> F</a></li>
<li><a class="" href="g.html"><span class="header-section-number">8</span> G</a></li>
<li><a class="" href="h.html"><span class="header-section-number">9</span> H</a></li>
<li><a class="" href="i.html"><span class="header-section-number">10</span> I</a></li>
<li><a class="" href="j.html"><span class="header-section-number">11</span> J</a></li>
<li><a class="" href="k.html"><span class="header-section-number">12</span> K</a></li>
<li><a class="active" href="l.html"><span class="header-section-number">13</span> L</a></li>
<li><a class="" href="m.html"><span class="header-section-number">14</span> M</a></li>
<li><a class="" href="n.html"><span class="header-section-number">15</span> N</a></li>
<li><a class="" href="o.html"><span class="header-section-number">16</span> O</a></li>
<li><a class="" href="p.html"><span class="header-section-number">17</span> P</a></li>
<li><a class="" href="q.html"><span class="header-section-number">18</span> Q</a></li>
<li><a class="" href="r.html"><span class="header-section-number">19</span> R</a></li>
<li><a class="" href="s.html"><span class="header-section-number">20</span> S</a></li>
<li><a class="" href="t.html"><span class="header-section-number">21</span> T</a></li>
<li><a class="" href="u.html"><span class="header-section-number">22</span> U</a></li>
<li><a class="" href="v.html"><span class="header-section-number">23</span> V</a></li>
<li><a class="" href="w.html"><span class="header-section-number">24</span> W</a></li>
<li><a class="" href="x.html"><span class="header-section-number">25</span> X</a></li>
<li><a class="" href="y.html"><span class="header-section-number">26</span> Y</a></li>
<li><a class="" href="z.html"><span class="header-section-number">27</span> Z</a></li>
</ul>

        <div class="book-extra">
          <p><a id="book-repo" href="https://github.com/psyteachr/glossary">View book source <i class="fab fa-github"></i></a></p>
        </div>
      </nav>
</div>
  </header><main class="col-sm-12 col-md-9 col-lg-7" id="content"><div id="l" class="section level1" number="13">
<h1>
<span class="header-section-number">13</span> L<a class="anchor" aria-label="anchor" href="#l"><i class="fas fa-link"></i></a>
</h1>

<div id="latex" class="section level2" number="13.1">
<h2>
<span class="header-section-number">13.1</span> LaTeX<a class="anchor" aria-label="anchor" href="#latex"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>A typesetting program needed to create PDF files from <a href="r.html#r-markdown">R Markdown</a> documents.</dfn></p>
<p><span class="math inline">\({\LaTeX}\)</span> is pronounced &lt;<lah-tech>&gt; or &lt;<lay-tech>&gt; (the X is a chi) and you can make the fancy version in <a href="r.html#r-markdown">R Markdown</a> using this code:</lay-tech></lah-tech></p>
<pre><code>${\LaTeX}$</code></pre>
<p><a href="https://www.latex-project.org" target="_blank"><span class="math inline">\({\LaTeX}\)</span> Project</a></p>

</div>
<div id="left_join" class="section level2" number="13.2">
<h2>
<span class="header-section-number">13.2</span> left_join<a class="anchor" aria-label="anchor" href="#left_join"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>A <a href="m.html#mutating-joins">mutating join</a> that keeps all the data from the first (left) table and joins anything that matches from the second (right) table.</dfn></p>
<div class="figure" style="text-align: center">
<span style="display:block;" id="fig:left-join"></span>
<img src="images/joins/left_join.png" alt="Left Join" width="100%"><p class="caption">
Figure 13.1: Left Join
</p>
</div>
<div class="sourceCode" id="cb122"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">X</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://tibble.tidyverse.org/reference/tibble.html">tibble</a></span><span class="op">(</span>
  id <span class="op">=</span> <span class="fl">1</span><span class="op">:</span><span class="fl">5</span>,
  x <span class="op">=</span> <span class="va">LETTERS</span><span class="op">[</span><span class="fl">1</span><span class="op">:</span><span class="fl">5</span><span class="op">]</span>
<span class="op">)</span>

<span class="va">Y</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://tibble.tidyverse.org/reference/tibble.html">tibble</a></span><span class="op">(</span>
  id <span class="op">=</span> <span class="fl">2</span><span class="op">:</span><span class="fl">6</span>,
  y <span class="op">=</span> <span class="va">LETTERS</span><span class="op">[</span><span class="fl">22</span><span class="op">:</span><span class="fl">26</span><span class="op">]</span>
<span class="op">)</span></code></pre></div>
<div class="inline-table"><table class="table table-sm">
<tr>
<th>
Table X
</th>
<th>
Table Y
</th>

</tr>
<tr>
<td>
<table class="table table-sm">
<thead><tr>
<th style="text-align:right;">
id
</th>
<th style="text-align:left;">
x
</th>
</tr></thead>
<tbody>
<tr>
<td style="text-align:right;">
1
</td>
<td style="text-align:left;">
A
</td>
</tr>
<tr>
<td style="text-align:right;">
2
</td>
<td style="text-align:left;">
B
</td>
</tr>
<tr>
<td style="text-align:right;">
3
</td>
<td style="text-align:left;">
C
</td>
</tr>
<tr>
<td style="text-align:right;">
4
</td>
<td style="text-align:left;">
D
</td>
</tr>
<tr>
<td style="text-align:right;">
5
</td>
<td style="text-align:left;">
E
</td>
</tr>
</tbody>
</table>
</td>
<td>
<table class="table table-sm">
<thead><tr>
<th style="text-align:right;">
id
</th>
<th style="text-align:left;">
y
</th>
</tr></thead>
<tbody>
<tr>
<td style="text-align:right;">
2
</td>
<td style="text-align:left;">
V
</td>
</tr>
<tr>
<td style="text-align:right;">
3
</td>
<td style="text-align:left;">
W
</td>
</tr>
<tr>
<td style="text-align:right;">
4
</td>
<td style="text-align:left;">
X
</td>
</tr>
<tr>
<td style="text-align:right;">
5
</td>
<td style="text-align:left;">
Y
</td>
</tr>
<tr>
<td style="text-align:right;">
6
</td>
<td style="text-align:left;">
Z
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</table></div>
<p>If there is no matching data in the right table for a row, the values are set to <a href="n.html#na">NA</a>.</p>
<div class="sourceCode" id="cb123"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="co"># X is the left table</span>
<span class="va">data</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate-joins.html">left_join</a></span><span class="op">(</span><span class="va">X</span>, <span class="va">Y</span>, by <span class="op">=</span> <span class="st">"id"</span><span class="op">)</span></code></pre></div>
<div class="inline-table"><table class="table table-sm">
<thead><tr>
<th style="text-align:right;">
id
</th>
<th style="text-align:left;">
x
</th>
<th style="text-align:left;">
y
</th>
</tr></thead>
<tbody>
<tr>
<td style="text-align:right;">
1
</td>
<td style="text-align:left;">
A
</td>
<td style="text-align:left;">
NA
</td>
</tr>
<tr>
<td style="text-align:right;">
2
</td>
<td style="text-align:left;">
B
</td>
<td style="text-align:left;">
V
</td>
</tr>
<tr>
<td style="text-align:right;">
3
</td>
<td style="text-align:left;">
C
</td>
<td style="text-align:left;">
W
</td>
</tr>
<tr>
<td style="text-align:right;">
4
</td>
<td style="text-align:left;">
D
</td>
<td style="text-align:left;">
X
</td>
</tr>
<tr>
<td style="text-align:right;">
5
</td>
<td style="text-align:left;">
E
</td>
<td style="text-align:left;">
Y
</td>
</tr>
</tbody>
</table></div>
<p>Order is important for left joins.</p>
<div class="sourceCode" id="cb124"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="co"># Y is the left table</span>
<span class="va">data</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate-joins.html">left_join</a></span><span class="op">(</span><span class="va">Y</span>, <span class="va">X</span>, by <span class="op">=</span> <span class="st">"id"</span><span class="op">)</span></code></pre></div>
<div class="inline-table"><table class="table table-sm">
<thead><tr>
<th style="text-align:right;">
id
</th>
<th style="text-align:left;">
y
</th>
<th style="text-align:left;">
x
</th>
</tr></thead>
<tbody>
<tr>
<td style="text-align:right;">
2
</td>
<td style="text-align:left;">
V
</td>
<td style="text-align:left;">
B
</td>
</tr>
<tr>
<td style="text-align:right;">
3
</td>
<td style="text-align:left;">
W
</td>
<td style="text-align:left;">
C
</td>
</tr>
<tr>
<td style="text-align:right;">
4
</td>
<td style="text-align:left;">
X
</td>
<td style="text-align:left;">
D
</td>
</tr>
<tr>
<td style="text-align:right;">
5
</td>
<td style="text-align:left;">
Y
</td>
<td style="text-align:left;">
E
</td>
</tr>
<tr>
<td style="text-align:right;">
6
</td>
<td style="text-align:left;">
Z
</td>
<td style="text-align:left;">
NA
</td>
</tr>
</tbody>
</table></div>
<p>See <a href="j.html#joins">joins</a> for other types of joins and further resources.</p>

</div>
<div id="level" class="section level2" number="13.3">
<h2>
<span class="header-section-number">13.3</span> level<a class="anchor" aria-label="anchor" href="#level"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>The set of valid values for a <a href="f.html#factor">factor</a></dfn></p>
<p>Setting the levels for a <a href="f.html#factor">factor</a> can be helpful to make sure they display and plot in the intended order.</p>
<div class="sourceCode" id="cb125"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="co"># levels in the right order</span>
<span class="va">day_levels</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Mon"</span>, <span class="st">"Tue"</span>, <span class="st">"Wed"</span>, <span class="st">"Thu"</span>, <span class="st">"Fri"</span>, <span class="st">"Sat"</span>, <span class="st">"Sun"</span><span class="op">)</span>

<span class="co"># repeat each day 1:7 times</span>
<span class="va">days</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/rep.html">rep</a></span><span class="op">(</span><span class="va">day_levels</span>, <span class="fl">1</span><span class="op">:</span><span class="fl">7</span><span class="op">)</span> 

<span class="co"># make into factors with and without levels</span>
<span class="va">without_levels</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/factor.html">factor</a></span><span class="op">(</span><span class="va">days</span><span class="op">)</span>
<span class="va">with_levels</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/factor.html">factor</a></span><span class="op">(</span><span class="va">days</span>, levels <span class="op">=</span> <span class="va">day_levels</span><span class="op">)</span></code></pre></div>
<div class="sourceCode" id="cb126"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu">ggplot</span><span class="op">(</span><span class="op">)</span> <span class="op">+</span> <span class="fu">geom_bar</span><span class="op">(</span><span class="fu">aes</span><span class="op">(</span>x <span class="op">=</span> <span class="va">without_levels</span><span class="op">)</span><span class="op">)</span></code></pre></div>
<div class="figure" style="text-align: center">
<span style="display:block;" id="fig:levels-without"></span>
<img src="_main_files/figure-html/levels-without-1.png" alt="Without setting levels, categories display in alphabetical order." width="100%"><p class="caption">
Figure 13.2: Without setting levels, categories display in alphabetical order.
</p>
</div>
<div class="sourceCode" id="cb127"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu">ggplot</span><span class="op">(</span><span class="op">)</span> <span class="op">+</span> <span class="fu">geom_bar</span><span class="op">(</span><span class="fu">aes</span><span class="op">(</span>x <span class="op">=</span> <span class="va">with_levels</span><span class="op">)</span><span class="op">)</span></code></pre></div>
<div class="figure" style="text-align: center">
<span style="display:block;" id="fig:levels-with"></span>
<img src="_main_files/figure-html/levels-with-1.png" alt="With setting levels, categories display in the level order" width="100%"><p class="caption">
Figure 13.3: With setting levels, categories display in the level order
</p>
</div>

</div>
<div id="library" class="section level2" number="13.4">
<h2>
<span class="header-section-number">13.4</span> library<a class="anchor" aria-label="anchor" href="#library"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>The <a href="l.html#library-function">function used to load packages</a> or the <a href="l.html#library-directory">directory where packages are stored</a>.</dfn></p>
</div>
<div id="library-function" class="section level2" number="13.5">
<h2>
<span class="header-section-number">13.5</span> library (function)<a class="anchor" aria-label="anchor" href="#library-function"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>The function used to load packages.</dfn></p>
<p>You can use the <code><a href="https://rdrr.io/r/base/library.html">library()</a></code> function to load <a href="p.html#package">packages</a>. This makes the functions in the package available to use without prefixing them with the package name.</p>
<p>If you try to use a non-prefixed function without loading its package, you will get an error like this:</p>
<div class="sourceCode" id="cb128"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="https://glue.tidyverse.org/reference/glue.html">glue</a></span><span class="op">(</span><span class="st">"My name is {name}"</span>, name <span class="op">=</span> <span class="st">"Lisa"</span><span class="op">)</span>
<span class="co">#&gt; Error in glue("My name is {name}", name = "Lisa"): could not find function "glue"</span></code></pre></div>
<p>You can use this function with its package prefix (helpfully, the <code><a href="https://glue.tidyverse.org/reference/glue.html">glue()</a></code> function comes from the glue package).</p>
<div class="sourceCode" id="cb129"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu">glue</span><span class="fu">::</span><span class="fu"><a href="https://glue.tidyverse.org/reference/glue.html">glue</a></span><span class="op">(</span><span class="st">"My name is {name}"</span>, name <span class="op">=</span> <span class="st">"Lisa"</span><span class="op">)</span>
<span class="co">#&gt; My name is Lisa</span></code></pre></div>
<p>Or you can load the package with <code><a href="https://rdrr.io/r/base/library.html">library()</a></code> and use it without the prefix.</p>
<div class="sourceCode" id="cb130"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://github.com/tidyverse/glue">glue</a></span><span class="op">)</span>

<span class="fu"><a href="https://glue.tidyverse.org/reference/glue.html">glue</a></span><span class="op">(</span><span class="st">"My name is {name}"</span>, name <span class="op">=</span> <span class="st">"Lisa"</span><span class="op">)</span>
<span class="co">#&gt; My name is Lisa</span></code></pre></div>
</div>
<div id="library-directory" class="section level2" number="13.6">
<h2>
<span class="header-section-number">13.6</span> library (directory)<a class="anchor" aria-label="anchor" href="#library-directory"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>The <a href="d.html#directory">directory</a> where <a href="p.html#package">packages</a> are stored.</dfn></p>
<p>Find out the location(s) where your packages are stored with the following code:</p>
<div class="sourceCode" id="cb131"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/base/libPaths.html">.libPaths</a></span><span class="op">(</span><span class="op">)</span>
<span class="co">#&gt; [1] "/Library/Frameworks/R.framework/Versions/4.1/Resources/library"</span></code></pre></div>
<p>If you have problems installing packages, you may need to change your library location to a directory that you have permission to write to. You can do this by setting the library path.</p>
<div class="sourceCode" id="cb132"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="co"># use a path relevant to your computer</span>
<span class="fu"><a href="https://rdrr.io/r/base/libPaths.html">.libPaths</a></span><span class="op">(</span><span class="st">"/Users/myaccount/R/Library"</span><span class="op">)</span></code></pre></div>

</div>
<div id="likert" class="section level2" number="13.7">
<h2>
<span class="header-section-number">13.7</span> Likert<a class="anchor" aria-label="anchor" href="#likert"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>A rating scale with a small number of discrete points in order</dfn></p>
<p>An example of a Likert scale is the following:</p>
<div class="inline-table"><table style="width:100%;" class="table table-sm">
<colgroup>
<col width="16%">
<col width="16%">
<col width="16%">
<col width="16%">
<col width="16%">
<col width="16%">
</colgroup>
<thead><tr class="header">
<th>Question</th>
<th>1 = Much less than average</th>
<th>2 = Less than average</th>
<th>3 = Average</th>
<th>4 = More than average</th>
<th>5 = Much more than average</th>
</tr></thead>
<tbody>
<tr class="odd">
<td>I like R</td>
<td><input type="radio" name="a"></td>
<td><input type="radio" name="a"></td>
<td><input type="radio" name="a"></td>
<td><input type="radio" name="a"></td>
<td><input type="radio" name="a"></td>
</tr>
<tr class="even">
<td>I like stats</td>
<td><input type="radio" name="b"></td>
<td><input type="radio" name="b"></td>
<td><input type="radio" name="b"></td>
<td><input type="radio" name="b"></td>
<td><input type="radio" name="b"></td>
</tr>
</tbody>
</table></div>
<p>The points on Likert scales are <a href="o.html#ordinal">ordinal</a>, but not necessarily <a href="c.html#continuous">continuous</a>. That is, you can assume 3 is higher than 2, but the difference between 2 and 3 isn't always the same as the difference between 1 and 2. Therefore, think carefully before averaging Likert values, since the average of 2 and 4 is not necessarily equal to 3.</p>

</div>
<div id="linear-mixed-effects-model" class="section level2" number="13.8">
<h2>
<span class="header-section-number">13.8</span> Linear mixed-effects model<a class="anchor" aria-label="anchor" href="#linear-mixed-effects-model"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>A type of regression model that involves estimating both <a href="f.html#fixed-effect">fixed effects</a> and <a href="r.html#random-effect">random effects</a>.</dfn></p>
<p>Most conventional regression models only estimate parameters associated with fixed effects and residual error. Mixed-effects models additionally estimate random effects parameters that capture variability associated with sampling units. In psychology, these sampling units are usually human participants or stimulus items.</p>
<p>Linear mixed-effects models are often called <strong>multi-level models</strong> or <strong>hierarchical models</strong>; these terms are roughly interchangeable. Linear mixed-effects models (LMEMs) are still <strong>linear models</strong> in the sense that they model a response variable in terms of a linear combination of predictor variables whose values are weighted by parameter estimates.</p>
<p>Because there is no closed form solution to finding the optimal parameter estimates, their values are typically estimated through an iterative procedure that searches the space of possible values for the optimum.</p>
<p>The function <code>lmer()</code> from the R package <strong><code>lme4</code></strong> is often used to estimate mixed-effects models. The <strong><code>brms</code></strong> package in R allows Bayesian estimation of mixed-effects models.</p>

</div>
<div id="list" class="section level2" number="13.9">
<h2>
<span class="header-section-number">13.9</span> list<a class="anchor" aria-label="anchor" href="#list"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>A <a href="c.html#container">container</a> data type that allows items with different data types to be grouped together.</dfn></p>
<p>Each item in a list can be any type of R <a href="o.html#object">object</a>, but is usually a <a href="v.html#vector">vector</a> or another list.</p>
<div class="sourceCode" id="cb133"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span>
  integers <span class="op">=</span> <span class="fl">1</span><span class="op">:</span><span class="fl">10</span>,
  strings <span class="op">=</span> <span class="va">LETTERS</span>,
  another_list <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span><span class="fl">1</span>, <span class="st">"A"</span>, <span class="cn">TRUE</span><span class="op">)</span>,
  object <span class="op">=</span> <span class="va">rnorm</span>
<span class="op">)</span>
<span class="co">#&gt; $integers</span>
<span class="co">#&gt;  [1]  1  2  3  4  5  6  7  8  9 10</span>
<span class="co">#&gt; </span>
<span class="co">#&gt; $strings</span>
<span class="co">#&gt;  [1] "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z"</span>
<span class="co">#&gt; </span>
<span class="co">#&gt; $another_list</span>
<span class="co">#&gt; $another_list[[1]]</span>
<span class="co">#&gt; [1] 1</span>
<span class="co">#&gt; </span>
<span class="co">#&gt; $another_list[[2]]</span>
<span class="co">#&gt; [1] "A"</span>
<span class="co">#&gt; </span>
<span class="co">#&gt; $another_list[[3]]</span>
<span class="co">#&gt; [1] TRUE</span>
<span class="co">#&gt; </span>
<span class="co">#&gt; </span>
<span class="co">#&gt; $object</span>
<span class="co">#&gt; function (n, mean = 0, sd = 1) </span>
<span class="co">#&gt; .Call(C_rnorm, n, mean, sd)</span>
<span class="co">#&gt; &lt;bytecode: 0x7f825d574d98&gt;</span>
<span class="co">#&gt; &lt;environment: namespace:stats&gt;</span></code></pre></div>

</div>
<div id="literal" class="section level2" number="13.10">
<h2>
<span class="header-section-number">13.10</span> literal<a class="anchor" aria-label="anchor" href="#literal"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>The actual character being typed, not the special meaning it has to code.</dfn></p>
<p>R and markdown have some characters that are used for code or formatting, making them difficult to use <em>literally</em> in the text. You can <a href="e.html#escape">escape</a> characters to use the literal version.</p>

</div>
<div id="logical" class="section level2" number="13.11">
<h2>
<span class="header-section-number">13.11</span> logical<a class="anchor" aria-label="anchor" href="#logical"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>A <a href="d.html#data-type">data type</a> representing <code>TRUE</code> or <code>FALSE</code> values.</dfn></p>
<p>Sometimes also called <a href="b.html#boolean">boolean</a></p>
<div class="sourceCode" id="cb134"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">true_logical_values</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span>
  full <span class="op">=</span> <span class="cn">TRUE</span>,
  abbreviated <span class="op">=</span> <span class="cn">T</span>,
  integer <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/logical.html">as.logical</a></span><span class="op">(</span><span class="fl">1</span><span class="op">)</span>,
  equation <span class="op">=</span> <span class="st">"A"</span> <span class="op">==</span> <span class="st">"A"</span>
<span class="op">)</span>
<span class="fu"><a href="https://rdrr.io/r/utils/str.html">str</a></span><span class="op">(</span><span class="va">true_logical_values</span><span class="op">)</span>
<span class="co">#&gt; List of 4</span>
<span class="co">#&gt;  $ full       : logi TRUE</span>
<span class="co">#&gt;  $ abbreviated: logi TRUE</span>
<span class="co">#&gt;  $ integer    : logi TRUE</span>
<span class="co">#&gt;  $ equation   : logi TRUE</span></code></pre></div>
<div class="sourceCode" id="cb135"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">false_logical_values</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span>
  full <span class="op">=</span> <span class="cn">FALSE</span>,
  abbreviated <span class="op">=</span> <span class="cn">F</span>,
  integer <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/logical.html">as.logical</a></span><span class="op">(</span><span class="fl">0</span><span class="op">)</span>,
  equation <span class="op">=</span> <span class="st">"A"</span> <span class="op">==</span> <span class="st">"B"</span>
<span class="op">)</span>

<span class="fu"><a href="https://rdrr.io/r/utils/str.html">str</a></span><span class="op">(</span><span class="va">false_logical_values</span><span class="op">)</span>
<span class="co">#&gt; List of 4</span>
<span class="co">#&gt;  $ full       : logi FALSE</span>
<span class="co">#&gt;  $ abbreviated: logi FALSE</span>
<span class="co">#&gt;  $ integer    : logi FALSE</span>
<span class="co">#&gt;  $ equation   : logi FALSE</span></code></pre></div>

</div>
<div id="long" class="section level2" number="13.12">
<h2>
<span class="header-section-number">13.12</span> long<a class="anchor" aria-label="anchor" href="#long"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>Data where each observation is on a separate row</dfn></p>
<div class="inline-table"><table class="table table-sm">
<caption>
<span id="tab:long-data">Table 13.1: </span>Long data
</caption>
<thead><tr>
<th style="text-align:left;">
id
</th>
<th style="text-align:left;">
item
</th>
<th style="text-align:right;">
value
</th>
</tr></thead>
<tbody>
<tr>
<td style="text-align:left;">
A
</td>
<td style="text-align:left;">
Q1
</td>
<td style="text-align:right;">
1
</td>
</tr>
<tr>
<td style="text-align:left;">
B
</td>
<td style="text-align:left;">
Q1
</td>
<td style="text-align:right;">
4
</td>
</tr>
<tr>
<td style="text-align:left;">
A
</td>
<td style="text-align:left;">
Q2
</td>
<td style="text-align:right;">
2
</td>
</tr>
<tr>
<td style="text-align:left;">
B
</td>
<td style="text-align:left;">
Q2
</td>
<td style="text-align:right;">
5
</td>
</tr>
<tr>
<td style="text-align:left;">
A
</td>
<td style="text-align:left;">
Q3
</td>
<td style="text-align:right;">
3
</td>
</tr>
<tr>
<td style="text-align:left;">
B
</td>
<td style="text-align:left;">
Q3
</td>
<td style="text-align:right;">
6
</td>
</tr>
</tbody>
</table></div>
<p>Contrast with <a href="w.html#wide">wide data</a>.</p>

</div>
</div>
<script>

/* update total correct if #webex-total_correct exists */
update_total_correct = function() {
  console.log("webex: update total_correct");

  if (t = document.getElementById("webex-total_correct")) {
    var correct = document.getElementsByClassName("webex-correct").length;
    var solvemes = document.getElementsByClassName("webex-solveme").length;
    var radiogroups = document.getElementsByClassName("webex-radiogroup").length;
    var selects = document.getElementsByClassName("webex-select").length;
    
    t.innerHTML = correct + " of " + (solvemes + radiogroups + selects) + " correct";
  }
}

/* webex-solution button toggling function */
b_func = function() {
  console.log("webex: toggle hide");
  
  var cl = this.parentElement.classList;
  if (cl.contains('open')) {
    cl.remove("open");
  } else {
    cl.add("open");
  }
}

/* function for checking solveme answers */
solveme_func = function(e) {
  console.log("webex: check solveme");

  var real_answers = JSON.parse(this.dataset.answer);
  var my_answer = this.value;
  var cl = this.classList;
  if (cl.contains("ignorecase")) {
    my_answer = my_answer.toLowerCase();
  }
  if (cl.contains("nospaces")) {
    my_answer = my_answer.replace(/ /g, "")
  }

  if (my_answer == "") {
    cl.remove("webex-correct");
    cl.remove("webex-incorrect");
  } else if (real_answers.includes(my_answer)) {
    cl.add("webex-correct");
    cl.remove("webex-incorrect");
  } else {
    cl.add("webex-incorrect");
    cl.remove("webex-correct");
  }

  // match numeric answers within a specified tolerance
  if(this.dataset.tol > 0){
    var tol = JSON.parse(this.dataset.tol);
    var matches = real_answers.map(x => Math.abs(x - my_answer) < tol)
    if (matches.reduce((a, b) => a + b, 0) > 0) {
      cl.add("webex-correct");
    } else {
      cl.remove("webex-correct");
    }
  }

  // added regex bit
  if (cl.contains("regex")){
    answer_regex = RegExp(real_answers.join("|"))
    if (answer_regex.test(my_answer)) {
      cl.add("webex-correct");
    }
  }

  update_total_correct();
}

/* function for checking select answers */
select_func = function(e) {
  console.log("webex: check select");
  
  var cl = this.classList
  
  /* add style */
  cl.remove("webex-incorrect");
  cl.remove("webex-correct");
  if (this.value == "answer") {
    cl.add("webex-correct");
  } else if (this.value != "blank") {
    cl.add("webex-incorrect");
  }
  
  update_total_correct();
}

/* function for checking radiogroups answers */
radiogroups_func = function(e) {
  console.log("webex: check radiogroups");

  var checked_button = document.querySelector('input[name=' + this.id + ']:checked');
  var cl = checked_button.parentElement.classList;
  var labels = checked_button.parentElement.parentElement.children;
  
  /* get rid of styles */
  for (i = 0; i < labels.length; i++) {
    labels[i].classList.remove("webex-incorrect");
    labels[i].classList.remove("webex-correct");
  }
  
  /* add style */
  if (checked_button.value == "answer") {
    cl.add("webex-correct");
  } else {
    cl.add("webex-incorrect");
  }
  
  update_total_correct();
}

window.onload = function() {
  console.log("onload");
  /* set up solution buttons */
  var buttons = document.getElementsByTagName("button");

  for (var i = 0; i < buttons.length; i++) {
    if (buttons[i].parentElement.classList.contains('webex-solution')) {
      buttons[i].onclick = b_func;
    }
  }

  /* set up webex-solveme inputs */
  var solveme = document.getElementsByClassName("webex-solveme");

  for (var i = 0; i < solveme.length; i++) {
    /* make sure input boxes don't auto-anything */
    solveme[i].setAttribute("autocomplete","off");
    solveme[i].setAttribute("autocorrect", "off");
    solveme[i].setAttribute("autocapitalize", "off");
    solveme[i].setAttribute("spellcheck", "false");
    solveme[i].value = "";

    /* adjust answer for ignorecase or nospaces */
    var cl = solveme[i].classList;
    var real_answer = solveme[i].dataset.answer;
    if (cl.contains("ignorecase")) {
      real_answer = real_answer.toLowerCase();
    }
    if (cl.contains("nospaces")) {
      real_answer = real_answer.replace(/ /g, "");
    }
    solveme[i].dataset.answer = real_answer;

    /* attach checking function */
    solveme[i].onkeyup = solveme_func;
    solveme[i].onchange = solveme_func;
  }
  
  /* set up radiogroups */
  var radiogroups = document.getElementsByClassName("webex-radiogroup");
  for (var i = 0; i < radiogroups.length; i++) {
    radiogroups[i].onchange = radiogroups_func;
  }
  
  /* set up selects */
  var selects = document.getElementsByClassName("webex-select");
  for (var i = 0; i < selects.length; i++) {
    selects[i].onchange = select_func;
  }

  update_total_correct();
}

</script><script>
$( document ).ready(function() {
  var cite = ' ';
  var psyteachr = ' <a href="https://psyteachr.github.io/"><img src="images/logos/psyteachr_logo.png" style="height: 31px; color: white;" alt="psyTeachR: Reproducible Research" /></a>';
  var license = ' <a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/" target="blank"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png"></a>';

  $("footer div.row div:eq(1) p").html(
    psyteachr + license + cite
  );
  
  $("#toc").appendTo($("#main-nav"));
});
</script><div class="chapter-nav">
<div class="prev"><a href="k.html"><span class="header-section-number">12</span> K</a></div>
<div class="next"><a href="m.html"><span class="header-section-number">14</span> M</a></div>
</div></main><div class="col-md-3 col-lg-2 d-none d-md-block sidebar sidebar-chapter">
    <nav id="toc" data-toggle="toc" aria-label="On this page"><h2>On this page</h2>
      <ul class="nav navbar-nav">
<li><a class="nav-link" href="#l"><span class="header-section-number">13</span> L</a></li>
<li><a class="nav-link" href="#latex"><span class="header-section-number">13.1</span> LaTeX</a></li>
<li><a class="nav-link" href="#left_join"><span class="header-section-number">13.2</span> left_join</a></li>
<li><a class="nav-link" href="#level"><span class="header-section-number">13.3</span> level</a></li>
<li><a class="nav-link" href="#library"><span class="header-section-number">13.4</span> library</a></li>
<li><a class="nav-link" href="#library-function"><span class="header-section-number">13.5</span> library (function)</a></li>
<li><a class="nav-link" href="#library-directory"><span class="header-section-number">13.6</span> library (directory)</a></li>
<li><a class="nav-link" href="#likert"><span class="header-section-number">13.7</span> Likert</a></li>
<li><a class="nav-link" href="#linear-mixed-effects-model"><span class="header-section-number">13.8</span> Linear mixed-effects model</a></li>
<li><a class="nav-link" href="#list"><span class="header-section-number">13.9</span> list</a></li>
<li><a class="nav-link" href="#literal"><span class="header-section-number">13.10</span> literal</a></li>
<li><a class="nav-link" href="#logical"><span class="header-section-number">13.11</span> logical</a></li>
<li><a class="nav-link" href="#long"><span class="header-section-number">13.12</span> long</a></li>
</ul>

      <div class="book-extra">
        <ul class="list-unstyled">
<li><a id="book-source" href="https://github.com/psyteachr/glossary/blob/master/terms/l.Rmd">View source <i class="fab fa-github"></i></a></li>
          <li><a id="book-edit" href="https://github.com/psyteachr/glossary/edit/master/terms/l.Rmd">Edit this page <i class="fab fa-github"></i></a></li>
        </ul>
</div>
    </nav>
</div>

</div>
</div> <!-- .container -->

<footer class="bg-primary text-light mt-5"><div class="container"><div class="row">

  <div class="col-12 col-md-6 mt-3">
    <p>"<strong>Glossary</strong>" was written by psyTeachR Team. It was last built on 2022-02-10.</p>
  </div>

  <div class="col-12 col-md-6 mt-3">
    <p>This book was built by the <a class="text-light" href="https://bookdown.org">bookdown</a> R package.</p>
  </div>

</div></div>
</footer><!-- dynamically load mathjax for compatibility with self-contained --><script>
  (function () {
    var script = document.createElement("script");
    script.type = "text/javascript";
    var src = "true";
    if (src === "" || src === "true") src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-MML-AM_CHTML";
    if (location.protocol !== "file:")
      if (/^https?:/.test(src))
        src = src.replace(/^https?:/, '');
    script.src = src;
    document.getElementsByTagName("head")[0].appendChild(script);
  })();
</script><script type="text/x-mathjax-config">const popovers = document.querySelectorAll('a.footnote-ref[data-toggle="popover"]');
for (let popover of popovers) {
  const div = document.createElement('div');
  div.setAttribute('style', 'position: absolute; top: 0, left:0; width:0, height:0, overflow: hidden; visibility: hidden;');
  div.innerHTML = popover.getAttribute('data-content');

  var has_math = div.querySelector("span.math");
  if (has_math) {
    document.body.appendChild(div);
    MathJax.Hub.Queue(["Typeset", MathJax.Hub, div]);
    MathJax.Hub.Queue(function() {
      popover.setAttribute('data-content', div.innerHTML);
      document.body.removeChild(div);
    })
  }
}
</script>
</body>
</html>
